

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/insert1.png">
  <link rel="icon" href="/img/insert1.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  
    <meta name="description" content="无聊的人生只剩下无尽的空虚。">
  
  <meta name="author" content="Mike Taylor">
  <meta name="keywords" content="我的博客">
  
  <title>CSS基础 - Mike Taylor</title>

  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@10.4.0/styles/github-gist.min.css" />
    
  

  
    <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
  



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    var CONFIG = {"hostname":"gitee.com","root":"/","version":"1.8.8","typing":{"enable":true,"typeSpeed":30,"cursorChar":"|","loop":false},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"right","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"copy_btn":true,"image_zoom":{"enable":true},"toc":{"enable":true,"headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"onlypost":false},"web_analytics":{"enable":false,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null}}};
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>Mike Taylor's</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                主页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                日志
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                目录
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                个人
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner" id="banner" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="page-header text-center fade-in-up">
            <span class="h2" id="subtitle" title="CSS基础">
              
            </span>

            
              <div class="mt-3">
  
    <span class="post-meta mr-2">
      <i class="iconfont icon-author" aria-hidden="true"></i>
      Mike Taylor
    </span>
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-03-15 14:27" pubdate>
        2021年3月15日 下午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      5.3k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      75
       分钟
    </span>
  

  
  
    
      <!-- 不蒜子统计文章PV -->
      <span id="busuanzi_container_page_pv" style="display: none">
        <i class="iconfont icon-eye" aria-hidden="true"></i>
        <span id="busuanzi_value_page_pv"></span> 次
      </span>
    
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">CSS基础</h1>
            
              <p class="note note-info">
                
                  本文最后更新于：2021年5月23日 下午
                
              </p>
            
            <div class="markdown-body">
              <h1 id="第三章-CSS基础"><a href="#第三章-CSS基础" class="headerlink" title="第三章 CSS基础"></a>第三章 CSS基础</h1><p><strong>课程提要</strong></p>
<ul>
<li>CSS介绍</li>
<li>CSS字体</li>
<li>CSS背景</li>
<li>CSS伪选择器</li>
<li>CSS属性&amp;&amp;关系选择器</li>
<li>CSS伪元素</li>
</ul>
<h2 id="3-1CSS介绍"><a href="#3-1CSS介绍" class="headerlink" title="3.1CSS介绍"></a>3.1CSS介绍</h2><p>层叠样式表（CSS），又称串样式列表，由W3C定义维护，一种用来结构化文档（HTML文档或者XML应用）添加样式（字体、间距和颜色等）的计算机语言。</p>
<p>CSS能对网页中元素位置的排版进行像素级精确控制，几乎所有字体字号样式，拥有对网页对象和模型样式编辑的能力。</p>
<h3 id="3-1-1-CSS的使用"><a href="#3-1-1-CSS的使用" class="headerlink" title="3.1.1 CSS的使用"></a>3.1.1 CSS的使用</h3><p>使用CSS可以让结构（HTM）与表现（CSS）分离，方便维护。</p>
<p>过去我们写网站都用table来布局，然后样式都直接加在table上面，这样一来页面显得特别臃肿，然后想修改一下也显得十分困难。</p>
<p>后来W3C推出了CSS，把结构和样式分离，HTML只负责结构，样式交给CSS来实现。这样一来，开发者工作量和效率大大提升，页面维护也变得容易，想要修改某个字体或者样式，直接在CSS文件中修改，不需要修改HTML结构。</p>
<h3 id="3-1-2-CSS基本语法"><a href="#3-1-2-CSS基本语法" class="headerlink" title="3.1.2 CSS基本语法"></a>3.1.2 CSS基本语法</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs css">选择器&#123;<br>		属性:属性值;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="3-1-3-CSS的四种引用方式"><a href="#3-1-3-CSS的四种引用方式" class="headerlink" title="3.1.3 CSS的四种引用方式"></a>3.1.3 CSS的四种引用方式</h3><p>CSS引用方式：行间样式、内部样式、外部样式、导入外部样式。</p>
<ul>
<li><p>行间样式（嵌入式样式）：直接在标签上书写样式。</p>
</li>
<li><p>内部样式：在文件内部书写样式。</p>
</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br>	样式内容<br><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br></code></pre></td></tr></table></figure>

<ul>
<li><p>外部样式：先创建一个CSS文件，再用link标签引入文件。</p>
</li>
<li><p>导入外部样式：先创建一个CSS文件，在style标签中使用import导入这个样式文件。</p>
</li>
</ul>
<p>以上四种CSS引用区别：</p>
<ul>
<li><p>行间样式只作用于当前标签；而内部样式只作用于当前文件；外部样式可以被多个HTML文件引用。</p>
</li>
<li><p>在实际开发中，最好使用外部样式（link使用更多）。</p>
</li>
<li><p>外部样式分为link引入和import引入两种方式。区别： </p>
<ul>
<li><strong>link是XHTML标签，除了加载CSS以外，还可以定义RSS等其他事物；@import属于CSS范畴，只能加载CSS。</strong></li>
<li>link引用CSS时，在页面载入时同时加载；@import需要页面网页完全载入后加载。</li>
<li>link是XHTML标签，无兼容性问题；@import是在CSS2.1提出，低版本浏览器不支持。</li>
<li><strong>link支持使用Javascript控制DOM去改变样式；而@import不支持。</strong></li>
</ul>
</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS的四种引用方式<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-comment">&lt;!--引入外部样式文件--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;CSS/201.1.css&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/css&quot;</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*导入外部样式*/</span></span><br><span class="css">        <span class="hljs-keyword">@import</span> <span class="hljs-string">&quot;CSS/201.2.css&quot;</span>;</span><br><span class="css">        <span class="hljs-selector-tag">p</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#eeeeee</span>;</span><br><span class="css">            <span class="hljs-attribute">font-size</span>:<span class="hljs-number">18px</span>;</span><br><span class="css">            <span class="hljs-attribute">font-style</span>:italic;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-comment">&lt;!--1.行间样式--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;color:olive;width:100px;border:1px solid blue;&quot;</span>&gt;</span>行间样式测试1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>行间样式测试1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br>    <span class="hljs-comment">&lt;!--2.内部样式表（见head部分）--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>段落一<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>段落二<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br><br>    <span class="hljs-comment">&lt;!--3.外部样式--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>外部样式测试<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>外部样式测试<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>外部样式测试<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>外部样式测试<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br><br>    <span class="hljs-comment">&lt;!--3.导入外部样式--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span>导入外部样式<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span>导入外部样式<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span>导入外部样式<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">em</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span>你好鸭<span class="hljs-tag">&lt;/<span class="hljs-name">em</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="3-1-4-CSS选择器"><a href="#3-1-4-CSS选择器" class="headerlink" title="3.1.4 CSS选择器"></a>3.1.4 CSS选择器</h3><p>1）*：匹配HTML中所有元素</p>
<p>​    注意：*的性能很差，因为要匹配所有元素，所以开发时不建议使用。</p>
<p>2）标签选择器：用来匹配对应的标签。</p>
<p>3）类选择器：用来匹配class命名的标签元素。</p>
<p>4）ID选择器：用来选择用id命名的标签。</p>
<p>5）派出选择器：根据上下文来确定选择的标签。</p>
<p>6）伪类选择器：后续讲</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>css选择器<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*!*1.* *!*/</span></span><br><span class="css">        <span class="hljs-comment">/**&#123;*/</span></span><br><span class="css">        <span class="hljs-comment">/*   color: red;*/</span></span><br><span class="css">        <span class="hljs-comment">/*&#125;*/</span></span><br><br><span class="css">        <span class="hljs-comment">/*2.标签选择器*/</span></span><br><span class="css">        <span class="hljs-selector-tag">span</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">display</span>: block;</span><br><span class="css">            <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">20px</span>;</span><br><span class="css">            <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid gray;</span><br>        &#125;<br><br><span class="css">        <span class="hljs-comment">/*3.类选择器*/</span></span><br>        .wrapper&#123;<br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#87faf8</span>;</span><br>        &#125;<br><br><span class="css">        <span class="hljs-comment">/*4.ID选择器*/</span></span><br>        #content&#123;<br><span class="css">            <span class="hljs-attribute">color</span>: pink;</span><br>        &#125;<br><br><span class="css">        <span class="hljs-comment">/*5.派出选择器*/</span></span><br><span class="css">        <span class="hljs-selector-class">.box2</span> <span class="hljs-selector-tag">li</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: blue;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-comment">&lt;!--1.*--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>这是P标签<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>这是strong标签<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><br><br>    <span class="hljs-comment">&lt;!--2.标签选择器--&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>这是span标签<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>这是div标签<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;wrapper&quot;</span>&gt;</span>这是div标签<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;content&quot;</span>&gt;</span>这是一个段落<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box1&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili4<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box2&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>bilibili3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>haha1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>haha2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>haha3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>            <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="3-1-5-选择器分组"><a href="#3-1-5-选择器分组" class="headerlink" title="3.1.5 选择器分组"></a>3.1.5 选择器分组</h3><p>对多个选择器进行分组，这样，    被分组的选择器就可以共享相同的声明。用逗号将需要的分组选择器分开。一般用于设置公共样式。</p>
<h3 id="3-1-6-选择器继承"><a href="#3-1-6-选择器继承" class="headerlink" title="3.1.6  选择器继承"></a>3.1.6  选择器继承</h3><p>子元素可以继承元素的样式，反之不可以。</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>选择器分组和样式继承<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/css&quot;</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*分组操作*/</span></span><br><span class="css">        <span class="hljs-selector-tag">h1</span>,<span class="hljs-selector-class">.box</span>,<span class="hljs-selector-tag">p</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: red;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">p</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">width</span>:<span class="hljs-number">100px</span>;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#999999</span>;</span><br><span class="css">            <span class="hljs-attribute">color</span>:blue;</span><br>        &#125;<br><span class="css">        <span class="hljs-comment">/*样式继承*/</span></span><br>        .test&#123;<br><span class="css">            <span class="hljs-attribute">font-size</span>: <span class="hljs-number">18px</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-class">.test</span> <span class="hljs-selector-tag">span</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">font-weight</span>: bold;</span><br><span class="css">            <span class="hljs-attribute">font-size</span>: <span class="hljs-number">28px</span>;<span class="hljs-comment">/*改写父元素传入的样式*/</span></span><br>        &#125;<br><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>h1<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box&quot;</span>&gt;</span> box内容<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>p<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;test&quot;</span>&gt;</span>这是一段测试<span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>内容<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>。<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="3-1-7-优先级"><a href="#3-1-7-优先级" class="headerlink" title="3.1.7 优先级"></a>3.1.7 优先级</h3><p>样式权重：</p>
<p>!important(10000)&gt;内联样式（1000）&gt;ID选择器（100）&gt;类、伪类选择器（10）&gt;标签选择器（1）</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>样式权重<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/css&quot;</span>&gt;</span><br><span class="css">        <span class="hljs-selector-tag">p</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>:blue/*<span class="hljs-meta">!important</span>*/;</span><br>        &#125;<br><br><span class="css">        <span class="hljs-selector-id">#content</span> <span class="hljs-selector-tag">div</span><span class="hljs-selector-class">.main_content</span> <span class="hljs-selector-tag">h2</span>&#123;<span class="hljs-comment">/*权重：100+1+10+1*/</span></span><br><span class="css">            <span class="hljs-attribute">color</span>: red;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-id">#content</span> <span class="hljs-selector-class">.main_content</span> <span class="hljs-selector-tag">h2</span>&#123;<span class="hljs-comment">/*权重：100+1+10*/</span></span><br><span class="css">            <span class="hljs-attribute">color</span>:blue;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;color:red;&quot;</span>&gt;</span>这是内容1<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>这是内容2<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-comment">&lt;!--内联样式权重大于标签选择器--&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;content&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;main_content&quot;</span>&gt;</span><br>            52<br>            <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><br>              这是一个标题<br>            <span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="3-2-CSS字体"><a href="#3-2-CSS字体" class="headerlink" title="3.2 CSS字体"></a>3.2 CSS字体</h2><ul>
<li><p>font-size：字号</p>
<ul>
<li>属性值<ul>
<li>{number+px}：固定尺寸像素</li>
<li>{number+%}：其百分比取值是基于父对象的尺寸大小</li>
</ul>
</li>
</ul>
</li>
<li><p>font-family：字体</p>
<ul>
<li>属性值<ul>
<li>name：字体名称，按优先顺序排列，以逗号隔开。<strong>若字体名称包含空格，则应该使用引号括起来</strong>。</li>
</ul>
</li>
</ul>
</li>
<li><p>font-style：样式</p>
<ul>
<li>属性值<ul>
<li>normal：默认值。正常字体。</li>
<li>italic：斜体，对于没有斜体变量的特殊字体，将应用oblique。</li>
<li>oblique：倾斜的字体。</li>
</ul>
</li>
</ul>
</li>
<li><p>font-weight：加粗</p>
<ul>
<li>属性值<ul>
<li>normal：默认值，正常字体。</li>
<li>bold：加粗。</li>
<li>bolder：比bold更粗。</li>
<li>lighter：比normal细。</li>
<li>{100-900}：定义粗到细的字符。400=normal，700=bold。</li>
</ul>
</li>
</ul>
</li>
<li><p>line-height：行高，字体底端与字体内部顶端之间的距离。</p>
<ul>
<li>属性值<ul>
<li>normal：默认行高，默认值。</li>
<li>{normal+px}：指定行高为长度像素。</li>
<li>{number}：指定行高为字体大小的倍数。</li>
</ul>
</li>
</ul>
</li>
<li><p>color：文字颜色</p>
<ul>
<li>属性值<ul>
<li>name：颜色名称指定color。</li>
<li>rgb：指定颜色为RGB。（0-255，三个分量）</li>
<li>{颜色十六进制}：指定颜色为16进制。（#开头，后跟六位（#rrggbb）或者三位（#rgb）</li>
</ul>
</li>
</ul>
</li>
<li><p>text-decoration：文字修饰</p>
<ul>
<li>属性值<ul>
<li>normal：默认值，无修饰。</li>
<li>underline：下划线。<ul>
<li>line-through：贯穿线。</li>
</ul>
</li>
<li>overline：上划线。</li>
</ul>
</li>
</ul>
</li>
<li><p>text-align：文本对齐方式</p>
<ul>
<li>属性值<ul>
<li>left：默认值，左对齐。</li>
<li>center：居中对齐。</li>
<li>right：右对齐。</li>
</ul>
</li>
</ul>
</li>
<li><p>text-transform：字母大小写</p>
<ul>
<li>none：默认值。</li>
<li>capitalize：将单词第一个字母转换成大写。</li>
<li>uppercase：所有文字转换成大写。</li>
<li>lowercase：所有文字转换成小写。</li>
</ul>
</li>
<li><p>text-indent：文本缩进</p>
<ul>
<li>属性值<ul>
<li>{number+px}：首行缩进number像素。</li>
<li>{number+em}：首行缩进number个字符。</li>
</ul>
</li>
</ul>
</li>
<li><p>font复合属性：</p>
<figure class="highlight maxima"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs maxima"><span class="hljs-built_in">font</span>:<span class="hljs-built_in">font</span>-<span class="hljs-built_in">style</span> <span class="hljs-built_in">font</span>-variant <span class="hljs-built_in">font</span>-weight <span class="hljs-built_in">font</span>-size/line-<span class="hljs-built_in">height</span> <span class="hljs-built_in">font</span>-family;<br></code></pre></td></tr></table></figure>

<p>1）注意属性值的位置顺序。</p>
<p>2）除了font-size和font-family，其他任何一个属性值都可以省略。</p>
<p>3）font-variant：文本修饰，normal/small-caps（让大写字母变得小一些）</p>
</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS字体属性<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-selector-tag">p</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">font-size</span>: <span class="hljs-number">28px</span>;</span><br><span class="css">            <span class="hljs-attribute">font-family</span>: 微软雅黑, 宋体, 黑体;</span><br><span class="css">            <span class="hljs-comment">/*font-style: italic;*/</span></span><br><span class="css">            <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">300</span>;</span><br><span class="css">            <span class="hljs-attribute">line-height</span>: <span class="hljs-number">2</span>;</span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#808011</span>;</span><br><span class="css">            <span class="hljs-attribute">text-align</span>: center;</span><br><span class="css">            <span class="hljs-attribute">text-transform</span>: capitalize;</span><br><span class="css">            <span class="hljs-attribute">text-indent</span>: <span class="hljs-number">2em</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">p</span> <span class="hljs-selector-tag">span</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">900</span>;</span><br><span class="css">            <span class="hljs-comment">/*color: #87faf8;*/</span></span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">122</span>,<span class="hljs-number">135</span>,<span class="hljs-number">255</span>);</span><br><span class="css">            <span class="hljs-attribute">text-decoration</span>: underline;</span><br><span class="css">            <span class="hljs-comment">/*text-decoration: line-through;*/</span></span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">strong</span> &#123;</span><br><span class="css">            <span class="hljs-attribute">font</span>: italic small-caps bolder <span class="hljs-number">8px</span>/<span class="hljs-number">2</span> 微软雅黑;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>中国沙尘暴主要发生在春季的3月～5月。<br>        中国工程院院士、中国气象科学研究院研究员张小曳向<br>        <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>《中国新闻周刊》<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>介绍，这次沙尘暴的起源，<br>        主要是在蒙古国戈壁沙漠的中部和南部，以及内蒙古的中部和西部沙漠。<br>        此次沙尘暴基本上朝东移动，未来主要影响的是长江以北地区，<br>        包括辽宁、河北、河南、山东，以及江苏部分地区，<br>        3月16日，沙尘暴将影响到上海。今日傍晚，此次沙尘暴对北京的影响将会结束。<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>text-decoration: line-through<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>辽宁、河北、河南、山东 hello<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="3-3-CSS背景"><a href="#3-3-CSS背景" class="headerlink" title="3.3 CSS背景"></a>3.3 CSS背景</h2><p>1）background-color：背景色（transparent/一种颜色）</p>
<p>2）background-image：背景图</p>
<ul>
<li>none</li>
<li>url{url}(使用绝对或者相对url指定背景图片)</li>
</ul>
<p>3）background-repeat:设置对象的背景图铺排方式</p>
<ul>
<li>repeat：默认值（背景图像在纵向和横向平铺）</li>
<li>no-repeat：背景图像不平铺</li>
<li>repeat-x：背景图像仅在横向平铺</li>
<li>repeat-y：背景图像仅在纵向平铺</li>
</ul>
<p>4）background-position：背景图像位置</p>
<ul>
<li>{x-number|top|center|bottom} {y-number|left|right|center}</li>
</ul>
<p>5）background-attachment：设置背景图像滚动的位置</p>
<ul>
<li>scroll：默认值，背景图像会随着页面其余部分的滚动而滚动。</li>
<li>fixed：当页面的其余部分滚动时，背景图像不会移动。</li>
</ul>
<p>6）background复合属性：设置背景的复合写法</p>
<p>顺序：背景色 图片url 是否平铺 是否固定滚动条 百分比 位置</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS背景<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*body&#123;*/</span></span><br><span class="css">        <span class="hljs-comment">/*    !*background-color: rgb(125,125,255);*!*/</span></span><br><span class="css">        <span class="hljs-comment">/*    background-image: url(https://s3.ax1x.com/2021/03/15/6Dxmyn.gif);*/</span></span><br><span class="css">        <span class="hljs-comment">/*    background-repeat: no-repeat;*/</span></span><br><span class="css">        <span class="hljs-comment">/*    background-position: top; !*如果只带一个参数，默认y方向为50%*!*/</span></span><br><span class="css">        <span class="hljs-comment">/*    background-attachment: fixed;!*scroll*!*/</span></span><br><span class="css">        <span class="hljs-comment">/*    height: 2000px;*/</span></span><br><span class="css">        <span class="hljs-comment">/*&#125;*/</span></span><br><span class="css">        <span class="hljs-selector-tag">body</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">background</span>: <span class="hljs-number">#888888</span> <span class="hljs-built_in">url</span>(<span class="hljs-string">https://s3.ax1x.com/2021/03/15/6Dxmyn.gif</span>) repeat-y scroll <span class="hljs-number">100px</span> <span class="hljs-number">200px</span>;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="3-4-CSS伪类选择器"><a href="#3-4-CSS伪类选择器" class="headerlink" title="3.4 CSS伪类选择器"></a>3.4 CSS伪类选择器</h2><p>伪类：专门用来表示元素的一种特殊状态。</p>
<p>常用的伪类选择器：</p>
<ul>
<li><p>a标签的伪类：</p>
<ul>
<li><code>a:visited</code>：已被访问状态</li>
<li><code>a:link</code>：未访问状态</li>
<li><code>a:hover</code>：鼠标悬停状态</li>
<li><code>a:active</code>：用户激活</li>
</ul>
</li>
<li><p>表单（:foucs）：表单获得焦点时的触发样式。</p>
</li>
<li><p>first-child：（:first-child/:last-child/nth-child(num)伪类来选择元素的第一个/最后/中间某个子元素）。</p>
</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS伪类选择器<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:link</span>&#123;</span><br><span class="css">            <span class="hljs-comment">/*link可以不写*/</span></span><br><span class="css">            <span class="hljs-attribute">color</span>: red;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:visited</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>:green;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:hover</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#8080ff</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">a</span><span class="hljs-selector-pseudo">:active</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>:deepskyblue;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">input</span><span class="hljs-selector-pseudo">:focus</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">outline</span>: <span class="hljs-number">1px</span> solid red;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span><span class="hljs-selector-pseudo">:first</span>-child&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: yellow;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span><span class="hljs-selector-pseudo">:nth-child</span>(<span class="hljs-number">3</span>)&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#8080ff</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span><span class="hljs-selector-pseudo">:last-child</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>:pink;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-comment">&lt;!----&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#&quot;</span>&gt;</span>单机我跳转<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>num1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>num2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>num3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>num4<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="3-5-属性和关系选择器"><a href="#3-5-属性和关系选择器" class="headerlink" title="3.5 属性和关系选择器"></a>3.5 属性和关系选择器</h2><h3 id="3-5-1-属性选择器"><a href="#3-5-1-属性选择器" class="headerlink" title="3.5.1 属性选择器"></a>3.5.1 属性选择器</h3><ul>
<li>[属性名]：包含有指定属性名的元素</li>
<li>[属性名=值]：属性名的值为指定值的元素</li>
<li>[属性名~=值]：属性名的值<strong>包含</strong>指定值得到元素</li>
<li>[属性名^=值]：属性名的值以指定值<strong>开头</strong>的元素</li>
<li>[属性名$=值]：属性名的值以指定值<strong>结尾</strong>的元素</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>属性选择器<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">    <span class="hljs-selector-tag">div</span><span class="hljs-selector-class">.content</span><span class="hljs-selector-attr">[title]</span>&#123;</span><br><span class="css">        <span class="hljs-attribute">font-weight</span>: bolder;</span><br>    &#125;<br><span class="css">    <span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[name=<span class="hljs-string">&quot;usr&quot;</span>]</span>&#123;</span><br><span class="css">        <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#8080ff</span>;</span><br>    &#125;<br><span class="css">    <span class="hljs-selector-tag">div</span><span class="hljs-selector-attr">[class^=box4]</span>&#123;</span><br><span class="css">        <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#809999</span>;</span><br>    &#125;<br><span class="css">    <span class="hljs-selector-tag">div</span><span class="hljs-selector-attr">[class~=box1]</span>&#123;</span><br><span class="css">        <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#808000</span>;</span><br>    &#125;<br><span class="css">    <span class="hljs-selector-tag">div</span><span class="hljs-selector-attr">[class$=box6]</span>&#123;</span><br><span class="css">        <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#ff8070</span>;</span><br>    &#125;<br><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;content box1 box2&quot;</span> <span class="hljs-attr">title</span>=<span class="hljs-string">&quot;内容&quot;</span>&gt;</span>content1<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;box4 box2&quot;</span>&gt;</span>content2<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;content box3 box6&quot;</span>&gt;</span>content3<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">&quot;&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;usr&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;account&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="3-5-2-关系选择器"><a href="#3-5-2-关系选择器" class="headerlink" title="3.5.2 关系选择器"></a>3.5.2 关系选择器</h3><p>1）空格：后代选择器</p>
<p>2）&gt;：只选择儿子元素</p>
<p>3）+：兄弟选择器</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>关系选择器<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-comment">/*!*后代选择器*!*/</span></span><br><span class="css">        <span class="hljs-comment">/*h1 strong&#123;*/</span></span><br><span class="css">        <span class="hljs-comment">/*    background-color: #000;*/</span></span><br><span class="css">        <span class="hljs-comment">/*    color:#fff;*/</span></span><br><span class="css">        <span class="hljs-comment">/*&#125;*/</span></span><br><span class="css">        <span class="hljs-comment">/*儿子选择器*/</span></span><br><span class="css">        <span class="hljs-selector-tag">h1</span>&gt;<span class="hljs-selector-tag">strong</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#000</span>;</span><br><span class="css">            <span class="hljs-attribute">color</span>:<span class="hljs-number">#fff</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-comment">/*兄弟选择器*/</span></span><br><br><span class="css">        <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span>+<span class="hljs-selector-tag">li</span>+<span class="hljs-selector-tag">li</span>&#123;</span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#8080ff</span>;</span><br>        &#125;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>关系一<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>关系二<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>内容1<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>内容2<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>内容3<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>内容4<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span>内容5<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br><span class="hljs-comment">&lt;!--</span><br><span class="hljs-comment">!!!!!</span><br><span class="hljs-comment">注意：从最后一个指出的兄弟开始生效，到第一个不同的兄弟终止。</span><br><span class="hljs-comment">--&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="3-5-3-CSS伪元素"><a href="#3-5-3-CSS伪元素" class="headerlink" title="3.5.3 CSS伪元素"></a>3.5.3 CSS伪元素</h3><p>CSS引入伪类和伪元素概念为了格式化文档树以外的信息。也就是说，伪类和伪元素是用来修饰不在文档树中的部分。</p>
<p>1）二者区别：</p>
<ul>
<li><p>伪类用于当已有元素处于的某个状态时，为其添加对应的样式，这个状态是根据用户行为而动态变化的。他只有处于dom树无法描述的状态下才能为元素添加样式，所以称之为伪类。</p>
</li>
<li><p>伪元素用于创建一些<strong>不在文档树</strong>中的元素，并为其添加样式，这个状态是根据用户行为而<strong>动态变化</strong>的。比如，我们可以通过:before来在一个元素前增加一些文本，并为这些文本添加样式。虽然用户可以看到这些文本，但是这些文本实际上不在文档树中。</p>
</li>
</ul>
<p>2）伪类&amp;伪元素的特点：</p>
<ul>
<li>伪元素和伪类都不会出现在源文档或者文档树中，<strong>鼠标无法选中</strong>。</li>
<li>伪类允许出现在选择器的任何位置，而一个伪元素只能跟在选择器的最后一个简单选择器后面。</li>
<li>伪元素名和伪类名都是大小写不敏感的。</li>
<li>有一些伪类的互斥的，而其他的可以同时用在同一元素上（在规则冲突的情况下，常规层叠顺序决定结果）。</li>
</ul>
<p>3）:before/:after/:first-letter/:first-line：前面可以是1个冒号，也可以是2个冒号。</p>
<p>4）::selection/::placeholder/::backdrop：前面只能是双冒号。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>CSS伪元素<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><br><span class="css">        <span class="hljs-selector-tag">p</span><span class="hljs-selector-pseudo">:first</span>-letter&#123;</span><br><span class="css">            <span class="hljs-attribute">font</span>: <span class="hljs-number">30px</span> 宋体;</span><br><span class="css">            <span class="hljs-attribute">color</span>: <span class="hljs-number">#8080ff</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">p</span><span class="hljs-selector-pseudo">:first</span>-line&#123;</span><br><span class="css">            <span class="hljs-attribute">text-decoration</span>: underline blue;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">p</span>:before&#123;</span><br><span class="css">            <span class="hljs-attribute">content</span>: <span class="hljs-string">&#x27;☯&#x27;</span>;</span><br>        &#125;<br><span class="css">        <span class="hljs-selector-tag">p</span>:after&#123;</span><br><span class="css">            <span class="hljs-attribute">content</span>: <span class="hljs-string">&#x27;……&#x27;</span>;</span><br>        &#125;<br><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>与八代产品线相比（如 8750H），我们发现 9750H 与 9850H 之间的差距已经变得更小，<br>            这或许也是它被大多数游戏笔记本所采纳的原因。<br>            或许是感受到了大家对于“挤牙膏”的怨念，英特尔决定至少专门推出一款有实质性提升的 9 代笔记本标压处理器。<br>            现在看来，9750H 也是唯一获得了 10~20% 频率提升的芯片。<br>        <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="第二次作业"><a href="#第二次作业" class="headerlink" title="第二次作业"></a>第二次作业</h2><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><code class="hljs css"><span class="hljs-selector-tag">h1</span>&#123;<br>    <span class="hljs-attribute">text-align</span>: center;<br>    <span class="hljs-attribute">font-family</span>: 宋体,微软雅黑;<br>    <span class="hljs-attribute">margin</span>: <span class="hljs-number">10px</span> <span class="hljs-number">0</span> <span class="hljs-number">20px</span>;<span class="hljs-comment">/*上边距20，左右边距0，下边距10*/</span><br>    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">30px</span>;<br>    <span class="hljs-attribute">font-weight</span>: normal;<br>&#125;<br><span class="hljs-selector-tag">body</span>&#123;<br>    <span class="hljs-attribute">background-image</span>: <span class="hljs-built_in">url</span>(<span class="hljs-string">&quot;https://s3.ax1x.com/2021/03/16/6s31gg.png&quot;</span>);<br>    <span class="hljs-attribute">background-repeat</span>: repeat-y;<br>    <span class="hljs-attribute">background-position</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>;<br>    <span class="hljs-attribute">background-attachment</span>: scroll;<br>    <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span> <span class="hljs-number">0</span>;<br>&#125;<br><span class="hljs-selector-id">#author</span>&#123;<br>    <span class="hljs-attribute">text-align</span>: center;<br>    <span class="hljs-attribute">font-weight</span>: bolder;<br>&#125;<br><span class="hljs-selector-tag">a</span>&#123;<br>    <span class="hljs-attribute">text-decoration</span>: none;<br>&#125;<br><span class="hljs-selector-id">#my_site</span><span class="hljs-selector-pseudo">:link</span>&#123;<br>    <span class="hljs-attribute">color</span>: <span class="hljs-number">#8080ff</span>;<br>&#125;<br><span class="hljs-selector-id">#my_site</span><span class="hljs-selector-pseudo">:visited</span>&#123;<br>    <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">225</span>, <span class="hljs-number">230</span>, <span class="hljs-number">200</span>);<br>&#125;<br><span class="hljs-selector-id">#my_site</span><span class="hljs-selector-pseudo">:hover</span>&#123;<br>    <span class="hljs-attribute">color</span>: <span class="hljs-number">#87faf8</span>;<br>&#125;<br><span class="hljs-selector-id">#my_site</span><span class="hljs-selector-pseudo">:active</span>&#123;<br>    <span class="hljs-attribute">color</span>: <span class="hljs-built_in">rgb</span>(<span class="hljs-number">255</span>, <span class="hljs-number">255</span>, <span class="hljs-number">0</span>);<br>&#125;<br><span class="hljs-selector-class">.content</span>&#123;<br>    <span class="hljs-attribute">color</span>: orchid;<br>    <span class="hljs-attribute">text-align</span>: left;<br>    <span class="hljs-attribute">text-indent</span>: <span class="hljs-number">2em</span>;<br>    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">30px</span>;<br>    <span class="hljs-attribute">margin</span>: <span class="hljs-number">1.5em</span> <span class="hljs-number">0</span>;<br>    <span class="hljs-attribute">line-height</span>: <span class="hljs-number">1.5em</span>;<br>&#125;<br><span class="hljs-selector-tag">h1</span>+<span class="hljs-selector-tag">p</span>+<span class="hljs-selector-tag">p</span>&#123;<br>    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">5px</span>;<br>    <span class="hljs-attribute">border-top</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#010101</span>;<br>    <span class="hljs-attribute">border-bottom</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#010101</span>;<br>    <span class="hljs-attribute">padding</span>: <span class="hljs-number">30px</span> <span class="hljs-number">0</span>;<br>    <span class="hljs-attribute">text-indent</span>: <span class="hljs-number">0</span>;<br>    <span class="hljs-attribute">color</span>: dodgerblue;<br>&#125;<br><span class="hljs-selector-class">.main</span>&#123;<br>    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#87faf8</span>;<br>    <span class="hljs-attribute">padding</span>: <span class="hljs-number">20px</span>;<br>    <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span> auto;<br>    <span class="hljs-attribute">width</span>: <span class="hljs-number">800px</span>;<br>&#125;<br><span class="hljs-selector-class">.summary</span>&#123;<br>    <span class="hljs-attribute">color</span>: red;<br>&#125;<br><span class="hljs-selector-tag">ul</span>&#123;<br>    <span class="hljs-attribute">color</span>: gray;<br>    <span class="hljs-attribute">list-style-type</span>: none;<span class="hljs-comment">/*取消列表前的point*/</span><br>    <span class="hljs-attribute">text-indent</span>: <span class="hljs-number">2em</span>;<br>    <span class="hljs-attribute">line-height</span>: <span class="hljs-number">2em</span>;<br>&#125;<br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>第三次作业<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;shortcut icon&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://s3.ax1x.com/2021/03/16/6s31gg.png&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;./CSS/第三次作业.css&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;main&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>3·15晚会已播30年 那些曾被点名的企业过得如何？<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;author&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;my_site&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;https://miketaylorjuly123.cn&quot;</span> <span class="hljs-attr">title</span>=<span class="hljs-string">&quot;作者&quot;</span> <span class="hljs-attr">target</span>=<span class="hljs-string">&quot;_blank&quot;</span>&gt;</span>张加林<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;abstract&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;summary&quot;</span>&gt;</span>摘要<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>：奇奇怪怪，古古怪怪，嘻嘻哈哈，吞吞吐吐<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;content&quot;</span>&gt;</span>盘点近10年来3·15晚会的“上榜”企业名单，作为一场维护普通消费者权益的公益晚会，3·15晚会所关注的领域，很多都与“衣食住行”相关。<br>        从数量来看，“衣食住行“这四个方面的企业和问题几乎就占据了3·15晚会“名单”的半壁江山。<br>        辣条生产乱象、山寨“六个核桃”、“化妆”鸡蛋等食品相关问题；H&amp;M、ZARA、ARMANI等服装品牌抽检不合格；方太、美的、西门子等家用电器售后服务的“套路”……<br>        作为中国最大的毛巾生产基地，河北省高阳县的一些厂家生产的毛巾无法保证检测合格<br>        在我国主要海参养殖区域之一山东即墨，养殖户为了清除不利于海参生长的其他生物，往池塘里加入了不少敌敌畏；此外，快餐企业汉堡王也被爆出售食品中包含过期食材<br>        在广州市黄埔开发区，万科旗下的“精装修”房万科尚城被称为“惊装修”：存在卫生间、插座漏水的状况，甚至渗透出来的是排粪水<br>        上汽通用五菱旗下的“神车”宝骏560，被爆出变速箱故障：在高速路上会突然失去动力，维修后仍故障不断，更换变速箱后一个月内挂倒挡动力又失效<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#&quot;</span>&gt;</span>你可能感兴趣相关内容1<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#&quot;</span>&gt;</span>你可能感兴趣相关内容2<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#&quot;</span>&gt;</span>你可能感兴趣相关内容3<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#&quot;</span>&gt;</span>你可能感兴趣相关内容4<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>开发思路：整体到局部，自上而下</p>
<p>选中标签中的所有内容快捷键：<code>ctrl</code>+<code>Alt</code>+<code>T</code></p>
<p>section(区块标签)</p>
<p>display:block</p>
<p><strong>导读标题到页内具体位置的操作</strong></p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;#title1&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> <span class="hljs-comment">&lt;!--导读标题--&gt;</span><br><span class="hljs-comment">&lt;!--href表示锚点，实现页内跳转--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;title1&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span> <span class="hljs-comment">&lt;!--跳转处--&gt;</span><br><span class="hljs-comment">&lt;!--这里的a标签是一个锚点--&gt;</span><br></code></pre></td></tr></table></figure>


            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/CSS/">CSS</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">
                  
                    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！
                  
                </p>
              
              
                <div class="post-prevnext">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2021/03/22/%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A07/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">CSS浮动&盒模型</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/03/10/%E9%87%91%E8%9E%8D%E5%AD%A6%E5%9F%BA%E7%A1%801/">
                        <span class="hidden-mobile">金融 第一周</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->

  <div class="col-lg-7 mx-auto nopadding-x-md">
    <div class="container custom post-custom mx-auto">
      <img src="https://octodex.github.com/images/jetpacktocat.png" srcset="/img/loading.gif" class="rounded mx-auto d-block mt-5" style="width:150px; height:150px;">
    </div>
  </div>


    

    
      <a id="scroll-top-button" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
    

    
  </main>

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  
  <!-- 备案信息 -->
  <div class="beian">
    <span>
      <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow noopener">
        京ICP证123456号
      </a>
    </span>
    
      
        <span>
          <a
            href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
            rel="nofollow noopener"
            class="beian-police"
            target="_blank"
          >
            
              <span style="visibility: hidden; width: 0">|</span>
              <img src="/img/police_beian.png" srcset="/img/loading.gif" alt="police-icon"/>
            
            <span>京公网安备12345678号</span>
          </a>
        </span>
      
    
  </div>


  
</footer>

<!-- SCRIPTS -->

  <script  src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" ></script>
<script  src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script  src="https://cdn.jsdelivr.net/npm/tocbot@4.12.0/dist/tocbot.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" ></script>



  <script  src="https://cdn.jsdelivr.net/npm/anchor-js@4.3.0/anchor.min.js" ></script>



  <script defer src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  <script  src="https://cdn.jsdelivr.net/npm/typed.js@2.0.11/lib/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var title = document.getElementById('subtitle').title;
      
      typing(title)
      
    })(window, document);
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    (function () {
      var path = "/local-search.xml";
      $('#local-search-input').on('click', function() {
        searchFunc(path, 'local-search-input', 'local-search-result');
      });
      $('#modalSearch').on('shown.bs.modal', function() {
        $('#local-search-input').focus();
      });
    })()
  </script>















<!-- 主题的启动项 保持在最底部 -->
<script  src="/js/boot.js" ></script>



<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>
</html>
